[PATCH] clk: mediatek: fix memory leak on module removal#57
Draft
akku1139 wants to merge 8 commits into
Draft
Conversation
Some MediaTek clock drivers do not call platform_set_drvdata() during probe(), but their remove() callback calls platform_get_drvdata(). This results in platform_get_drvdata() returning NULL, which leads to calling mtk_free_clk_data(NULL) -> kfree(NULL). Therefore, the actual clk_data is never released, causing a memory leak. Fix this by calling platform_set_drvdata() during probe. Fixes: 124294f ("clk: mediatek: mt8192: Move apmixedsys clock driver to its own file") Fixes: 4c02c9a ("clk: mediatek: mt8173: Break down clock drivers and allow module build") Fixes: 54b7026 ("clk: mediatek: mt8135-apmixedsys: Convert to platform_driver and module") Fixes: c50e2ea ("clk: mediatek: mt7622-apmixedsys: Add .remove() callback for module build") Fixes: 0d36328 ("clk: mediatek: Add MediaTek Helio X10 MT6795 clock drivers") Fixes: c6368ce ("clk: mediatek: mt2712-apmixedsys: Add .remove() callback for module build") Fixes: 838b863 ("clk: mediatek: mt7622: Move infracfg to clk-mt7622-infracfg.c") Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Revert "clk: mediatek: fix memory leak on module removal" This reverts commit 1cc6568.
Member
Author
|
for v2
|
Member
Author
|
clk_mt2712_apmixed_probe() in clk-mt2712-apmixedsys.c does not call platform_set_drvdata(), but clk_mt2712_apmixed_remove() callback calls platform_get_drvdata(). This results in platform_get_drvdata() returning NULL, which leads to calling kfree(NULL) in mtk_free_clk_data(NULL). This leaves clk_data unreleased, causing a memory leak. Fix this by calling platform_set_drvdata() during probe. Fixes: c6368ce ("clk: mediatek: mt2712-apmixedsys: Add .remove() callback for module build") Cc: stable@vger.kernel.org Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
clk-mt6795-apmixedsys.c, clk-mt6795-infracfg.c and clk-mt6795-pericfg.c do not call platform_set_drvdata() during their driver probe callback, but their remove callback calls platform_get_drvdata(). This results in platform_get_drvdata() returning NULL, which leads to calling kfree(NULL) in mtk_free_clk_data(NULL). This leaves clk_data unreleased, causing a memory leak. Fix this by calling platform_set_drvdata() during probe. Fixes: 0d36328 ("clk: mediatek: Add MediaTek Helio X10 MT6795 clock drivers") Cc: stable@vger.kernel.org Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
clk-mt7622-apmixedsys.c and clk-mt7622-infracfg.c do not call platform_set_drvdata() during their driver probe callback, but their remove callback calls platform_get_drvdata(). This results in platform_get_drvdata() returning NULL, which leads to calling kfree(NULL) in mtk_free_clk_data(NULL). This leaves clk_data unreleased, causing a memory leak. Fix this by calling platform_set_drvdata() during probe. Fixes: c50e2ea ("clk: mediatek: mt7622-apmixedsys: Add .remove() callback for module build") Fixes: 838b863 ("clk: mediatek: mt7622: Move infracfg to clk-mt7622-infracfg.c") Cc: stable@vger.kernel.org Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
clk_mt8135_apmixed_probe() in clk-mt8135-apmixedsys.c does not call platform_set_drvdata(), but clk_mt8135_apmixed_remove() callback calls platform_get_drvdata(). This results in platform_get_drvdata() returning NULL, which leads to calling kfree(NULL) in mtk_free_clk_data(NULL). This leaves clk_data unreleased, causing a memory leak. Fix this by calling platform_set_drvdata() during probe. Fixes: 54b7026 ("clk: mediatek: mt8135-apmixedsys: Convert to platform_driver and module") Cc: stable@vger.kernel.org Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
clk-mt8173-apmixedsys.c and clk-mt8173-infracfg.c do not call platform_set_drvdata() during their driver probe callback, but their remove callback calls platform_get_drvdata(). This results in platform_get_drvdata() returning NULL, which leads to calling kfree(NULL) in mtk_free_clk_data(NULL). This leaves clk_data unreleased, causing a memory leak. Fix this by calling platform_set_drvdata() during probe. Fixes: 4c02c9a ("clk: mediatek: mt8173: Break down clock drivers and allow module build") Cc: stable@vger.kernel.org Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
clk_mt8192_apmixed_probe() in clk-mt8192-apmixedsys.c does not call platform_set_drvdata(), but clk_mt8192_apmixed_remove() callback calls platform_get_drvdata(). This results in platform_get_drvdata() returning NULL, which leads to calling kfree(NULL) in mtk_free_clk_data(NULL). This leaves clk_data unreleased, causing a memory leak. Fix this by calling platform_set_drvdata() during probe. Fixes: 124294f ("clk: mediatek: mt8192: Move apmixedsys clock driver to its own file") Cc: stable@vger.kernel.org Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some MediaTek clock drivers do not call platform_set_drvdata() during probe(), but their remove() callback calls platform_get_drvdata(). This results in platform_get_drvdata() returning NULL, which leads to calling mtk_free_clk_data(NULL) -> kfree(NULL).
Therefore, the actual clk_data is never released, causing a memory leak.
Fix this by calling platform_set_drvdata() during probe.
Fixes: 124294f ("clk: mediatek: mt8192: Move apmixedsys clock driver to its own file")
Fixes: 4c02c9a ("clk: mediatek: mt8173: Break down clock drivers and allow module build")
Fixes: 54b7026 ("clk: mediatek: mt8135-apmixedsys: Convert to platform_driver and module")
Fixes: c50e2ea ("clk: mediatek: mt7622-apmixedsys: Add .remove() callback for module build")
Fixes: 0d36328 ("clk: mediatek: Add MediaTek Helio X10 MT6795 clock drivers")
Fixes: c6368ce ("clk: mediatek: mt2712-apmixedsys: Add .remove() callback for module build")
Fixes: 838b863 ("clk: mediatek: mt7622: Move infracfg to clk-mt7622-infracfg.c")